package com.adidas.dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import com.adidas.bean.AdidasUser;

public class AdidasDao {
//	
//	public void updateUserStatus(Map<String, String> mapList,Connection c) {
//		Statement stmt = null;
//		try {
//			c.setAutoCommit(false);
//			stmt = c.createStatement();
//			String sql = "update user set "
//					+"userstatus='"+mapList.get("userstatus")+"' "
//					+"where phone='"+mapList.get("phone")+"'";
//			System.out.println(sql);
//			stmt.executeUpdate(sql);
//			stmt.close();
//			c.commit();
//			
//		} catch (Exception e) {
//			e.printStackTrace();
//			System.err.println(e.getClass().getName() + ": " + e.getMessage());
//		}
//	}
	
	public List<AdidasUser> getUserLogin(Connection c){
		Statement stmt = null;
		List<AdidasUser> list = new ArrayList<AdidasUser>();
		try {
			c.setAutoCommit(false);
			stmt = c.createStatement();
			String sql = "select telphone,password"
					+ " from adiuser "
					+ " where 1=1 "
					+ " and loginstatus='0' "
					+ " limit 200";
			System.out.println(sql);
			ResultSet rs = stmt.executeQuery(sql);
			while (rs.next()) {
				AdidasUser adidasUser = new AdidasUser();
				adidasUser.setTelphone(rs.getString("telphone"));
				adidasUser.setPassword(rs.getString("password"));
				list.add(adidasUser);
			}
			c.commit();
		} catch (Exception e) {
			e.printStackTrace();
			System.err.println(e.getClass().getName() + ": " + e.getMessage());
		}
		return list;
	}
	
}
